package com.d0326;

import java.util.Set;
import java.util.TreeSet;

public class TestTreeSet {
    public static void main(String[] args) {
        //TreeSet特点可以自动排序
        Set<Student> treeSet = new TreeSet(new StudentAgeComeparetor());
        Student stu1 = new Student("Bright", 22, 100);
        Student stu2 = new Student("Win", 20, 95);
        Student stu3 = new Student("Jack", 25, 98);
        treeSet.add(stu1);
        treeSet.add(stu2);
        treeSet.add(stu3);
        System.out.println("个数是:" + treeSet.size());
        for (Student s : treeSet
        ) {
            System.out.println(s);
        }
    }
}

